/**
 * Created by Tang on 2017/7/17.
 */
$('#menu').on({
    'mouseenter':function () {
        $('.menu').slideDown(300);
    },
    'mouseleave':function () {
        $('.menu').slideUp(300);
    }
});

$('#id').on({
    'mouseenter':function () {
        $('.id').slideDown(300);
    },
    'mouseleave':function () {
        $('.id').slideUp(300);
    }
});

$('.kind').on({
    'mouseenter':function () {
        $('.kind>div').slideDown(300);
    },
    'mouseleave':function () {
        $('.kind>div').slideUp(300);
    }
});

$.ajax({
    url:'http://localhost:2403/books',
    type:'get',
    success:function (data) {
        for (var i in data){
            $('<div>').html('<img src="img/books' + rand(1,5) + '.jpg" alt=""><div><p><span class="name">' + data[i].name + '</span><span class="red">即时配发</span></p><p><span class="author">' + data[i].author + '(著)</span>|<span class="company">' + data[i].company + '</span>| <span>9787115444936</span>|<span class="time">' + data[i].time + '</span></p><p>[0人评价]</p><p>vip价:<span class="price">' + data[i].price + '(折扣)</span></p></div>').appendTo($('.m_right'))
        }
    }
});

function rand(min,max) {
    return parseInt(Math.random() * (max - min + 1) + min);
};